package lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

public class LearnLambda3 {
	
	public static void main(String[] args) {
		List<Person> persons = new ArrayList<Person>(); 
		persons.add(new Person("zhangsan", "jisuanji", 58));
		persons.add(new Person("lisi", "xinxi", 77));
		persons.add(new Person("wangwu", "huagong", 60));
		persons.add(new Person("zhaoliu", "waiguoyu", 86));
		persons.add(new Person("sunqi", "lixue", 83));
		LearnLambda3 lam = new LearnLambda3();
		lam.filterPrint(persons, (Person p) -> "huaxue".equals(p.department));
		System.out.println("======================================");
		lam.filterPrint(persons, (Person p) -> p.name.startsWith("zhao"));
		System.out.println("======================================");
		lam.filterPrint(persons, (Person p) -> p.score < 70);
	

	}
	
	public void filterPrint(List<Person> persons, Predicate<Person> predicate) {
		for(Person p : persons) {
			if(predicate.test(p)) System.out.println(p.name);
		}
	}


}
